#ifndef _LD_BUTTON_H_
#define _LD_BUTTON_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "ldCommon.h"

#define SELECT_COLOR_OPACITY     128

typedef struct {
    LD_COMMON_ATTRIBUTES;
    bool isTransparent:1;
    bool isCheckable:1;
    bool isChecked:1;
    bool isPressed:1;
    bool isSelected:1;
    bool isWithReleaseMask:1;
    bool isWithPressMask:1;
    bool isReleaseMaskOnly:1;
    bool isPressMaskOnly:1;
    bool isCorner:1;
    uintptr_t releaseImgAddr;
    uintptr_t pressImgAddr;
    uintptr_t selectMaskAddr;
    uint32_t keyValue;
    ldFontDict_t* pFontDict;
    uint8_t* pStr;
    uint8_t align:4;
    ldColor charColor;
    ldColor releaseColor;
    ldColor pressColor;
    ldColor selectColor;
}ldButton_t;

ldButton_t* ldButtonInit(arm_2d_scene_t *pScene,uint16_t nameId, uint16_t parentNameId, int16_t x,int16_t y,int16_t width,int16_t height);
void ldButtonFrameUpdate(ldButton_t* pWidget);
void ldButtonLoop(arm_2d_scene_t *pScene,ldButton_t *pWidget,const arm_2d_tile_t *pParentTile,bool bIsNewFrame);
void ldButtonDel(ldButton_t *pWidget);

void ldButtonSetColor(ldButton_t* pWidget, ldColor releaseColor, ldColor pressColor);
void ldButtonSetImage(ldButton_t* pWidget,uintptr_t releaseImgAddr,ldImageType_t releaseMaskType,uintptr_t pressImgAddr,ldImageType_t pressMaskType);
void ldButtonSetSelectImage(ldButton_t* pWidget,uintptr_t selectMaskAddr,ldColor selectColor);

void ldButtonSetTransparent(ldButton_t* pWidget,bool isTransparent);
void ldButtonSetRoundCorner(ldButton_t* pWidget,bool isCorner);
void ldButtonSetSelect(ldButton_t* pWidget,bool isSelected);

void ldButtonSetFont(ldButton_t *pWidget, ldFontDict_t *pFontDict);
void ldButtonSetText(ldButton_t* pWidget,uint8_t *pStr);
void ldButtonSetTextColor(ldButton_t* pWidget,ldColor charColor);
void ldButtonSetAlign(ldButton_t *pWidget,uint8_t align);

void ldButtonSetCheckable(ldButton_t *pWidget,bool isCheckable);

#define ldButtonSetHidden          ldBaseSetHidden
#define ldButtonMove               ldBaseMove

#ifdef __cplusplus
}
#endif

#endif //_LD_BUTTON_H_
